package com.hk.crm.workbench.service.impl;

import com.hk.crm.VO.PaginationVO;
import com.hk.crm.workbench.dao.ClueDao;
import com.hk.crm.workbench.domain.Clue;
import com.hk.crm.workbench.service.ClueService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service
public class ClueServiceImpl implements ClueService {
    @Resource
    private ClueDao proxyClueDao;


    @Override
    public boolean saveClue(Clue clue) {
        boolean flag=true;
        int count=proxyClueDao.addClue(clue);
        if (count!=1){
            flag=false;
        }
        return flag;
    }

    @Override
    public PaginationVO<Clue> pageList(Map<String, Object> map) {
        //        取得total
        int total=proxyClueDao.getTotalByCondition(map);
//        取得dataList
        List<Clue> dataList= proxyClueDao.getClueListByCondition(map);
//        将total和dataList封装到VO中
        PaginationVO<Clue> vo=new PaginationVO<>();
        vo.setTotal(total);
        vo.setDatalist(dataList);
//        将VO返回
        return vo;
    }

    @Override
    public Clue detail(String id) {
        Clue c=proxyClueDao.detail(id);
        return c;
    }

    @Override
    public boolean deleteById(String id) {
        boolean flag=true;
        int count=proxyClueDao.deleteById(id);
        if (count!=1){
            flag=false;
        }
        return flag;
    }
}
